﻿<Application x:Class="DoubanFM.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <Style x:Key="imageStyle" TargetType="{x:Type Image}">
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Trigger.EnterActions>
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation To="0.5" Duration="0:0:0.1"  Storyboard.TargetProperty="Opacity" />
                            </Storyboard>
                        </BeginStoryboard>
                    </Trigger.EnterActions>
                    <Trigger.ExitActions>
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation To="1.0" Duration="0:0:0.1"  Storyboard.TargetProperty="Opacity" />
                            </Storyboard>
                        </BeginStoryboard>
                    </Trigger.ExitActions>
                </Trigger>
            </Style.Triggers>
        </Style>
        
        <Style x:Key="labelStyle" TargetType="{x:Type Label}">
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Trigger.EnterActions>
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation To="0.5" Duration="0:0:0.1"  Storyboard.TargetProperty="Opacity" />
                            </Storyboard>
                        </BeginStoryboard>
                    </Trigger.EnterActions>
                    <Trigger.ExitActions>
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation To="1.0" Duration="0:0:0.1"  Storyboard.TargetProperty="Opacity" />
                            </Storyboard>
                        </BeginStoryboard>
                    </Trigger.ExitActions>
                </Trigger>
            </Style.Triggers>
        </Style>
        
        <Style x:Key="{x:Type ContextMenu}" TargetType="ContextMenu">
            <Setter Property="OverridesDefaultStyle" Value="True"/>
            <Setter Property="SnapsToDevicePixels" Value="True"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ContextMenu}">
                        <Border Margin="1" Background="{TemplateBinding Background}" CornerRadius="5" BorderThickness="0.5" >
                            <ItemsPresenter/>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="{x:Type MenuItem}" TargetType="MenuItem">
            <Setter Property="OverridesDefaultStyle" Value="True"/>
            <Setter Property="SnapsToDevicePixels" Value="True"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type MenuItem}">
                        <Border x:Name="border">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="30" SharedSizeGroup="MenuItemIconColumnGroup"/>
                                    <ColumnDefinition Width="Auto" SharedSizeGroup="MenuTextColumnGroup"/>
                                    <ColumnDefinition Width="14"/>
                                </Grid.ColumnDefinitions>
                                <ContentPresenter Grid.Column="0" 
                                      Margin="4,0,6,0" 
                                      x:Name="Icon" 
                                      VerticalAlignment="Center" 
                                      ContentSource="Icon"/>
                                <ContentPresenter Grid.Column="1"
                                      Margin="{TemplateBinding Padding}"
                                      x:Name="HeaderHost"
                                      RecognizesAccessKey="True"
                                      VerticalAlignment="Center" 
                                      ContentSource="Header"/>
                                <Grid Grid.Column="2" Margin="4,0,6,0" x:Name="ArrowPanel" VerticalAlignment="Center">
                                    <Path x:Name="ArrowPanelPath" HorizontalAlignment="Right" VerticalAlignment="Center" Fill="Red" Data="M0,0 L0,8 L4,4 z"/>
                                </Grid>

                                <Popup x:Name="popup" Placement="Right" PlacementTarget="{Binding ElementName=border}" AllowsTransparency="True">
                                    <Border Margin="0" Background="Cornsilk">
                                        <StackPanel IsItemsHost="True"></StackPanel>
                                    </Border>
                                </Popup>
                                <!--<Popup IsOpen="{TemplateBinding IsSubmenuOpen}" Placement="Right" AllowsTransparency="True" Focusable="False">
                                    <Border Margin="1" Background="Green">
                                        
                                        <StackPanel IsItemsHost="True"  KeyboardNavigation.DirectionalNavigation="Cycle"></StackPanel>
                                    </Border>
                                </Popup>-->
                            </Grid>
                        </Border>

                        <ControlTemplate.Triggers>
                            <Trigger Property="IsHighlighted" Value="True" >
                                <Setter Property="IsOpen" Value="True" TargetName="popup" />
                                <Setter Property="Background" Value="Green" TargetName="border"/>
                                <Setter Property="BorderBrush" Value="Black" TargetName="border"/>

                            </Trigger>
                            <!-- Role = TopLevelItem :  this is a child menu item from the top level without any child items-->
                            <Trigger Property="Role" Value="TopLevelItem">
                                <Setter Property="Padding" Value="6,1,6,1"/>
                                <Setter Property="Visibility" Value="Collapsed" TargetName="ArrowPanel"/>
                            </Trigger>

                            <!-- Role = SubMenuHeader : this is a child menu item which does not have children -->
                            <Trigger Property="Role" Value="SubmenuHeader">
                                <Setter Property="DockPanel.Dock" Value="Top"/>
                                <Setter Property="Padding" Value="0,2,0,2"/>
                            </Trigger>

                            <!-- Role = SubMenuItem : this is a child menu item which has children-->
                            <Trigger Property="Role" Value="SubmenuItem">
                                <Setter Property="DockPanel.Dock" Value="Top"/>
                                <Setter Property="Padding" Value="0,2,0,2"/>
                                <Setter Property="Visibility" Value="Collapsed" TargetName="ArrowPanel"/>
                            </Trigger>

                            <Trigger Property="Icon" Value="{x:Null}">
                                <Setter TargetName="Icon" Property="Visibility" Value="Collapsed"/>
                            </Trigger>
                            <!-- Using the system colors for the Menu Highlight and IsEnabled-->
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="LightGray"/>
                            </Trigger>
                        </ControlTemplate.Triggers>

                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style TargetType="ProgressBar">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ProgressBar">
                        <Border BorderBrush="{TemplateBinding BorderBrush}"
                               BorderThickness="{TemplateBinding BorderThickness}">
                            <Grid>
                                <Rectangle Fill="{TemplateBinding Background}"
                                          Name="PART_Track" />
                                <Rectangle Fill="{TemplateBinding Foreground}"
                                          Name="PART_Indicator"
                                          HorizontalAlignment="Left"/>
                            </Grid>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style TargetType="{x:Type Slider}">
            <Setter Property="Stylus.IsPressAndHoldEnabled" Value="False"/>
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Slider}">
                        <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Width="{TemplateBinding Width}">
                            <Grid>
                                <Border CornerRadius="1">
                                    <Rectangle Margin="-2" Opacity="0.5" Fill="{TemplateBinding Foreground}" Height="2" />
                                </Border>
                                <Track x:Name="PART_Track">
                                    <Track.DecreaseRepeatButton>
                                        <RepeatButton Command="Slider.DecreaseLarge">
                                            <RepeatButton.Style>
                                                <Style TargetType="{x:Type RepeatButton}">
                                                    <Setter Property="OverridesDefaultStyle" Value="True"/>
                                                    <Setter Property="IsTabStop" Value="False"/>
                                                    <Setter Property="Focusable" Value="False"/>
                                                    <Setter Property="Background" Value="Transparent"/>
                                                    <Setter Property="Template">
                                                        <Setter.Value>
                                                            <ControlTemplate TargetType="{x:Type RepeatButton}">
                                                                <Border Background="{TemplateBinding Background}"/>
                                                            </ControlTemplate>
                                                        </Setter.Value>
                                                    </Setter>
                                                </Style>
                                            </RepeatButton.Style>
                                        </RepeatButton>
                                    </Track.DecreaseRepeatButton>
                                    <Track.IncreaseRepeatButton>
                                        <RepeatButton Command="Slider.IncreaseLarge">
                                            <RepeatButton.Style>
                                                <Style TargetType="{x:Type RepeatButton}">
                                                    <Setter Property="OverridesDefaultStyle" Value="True"/>
                                                    <Setter Property="IsTabStop" Value="False"/>
                                                    <Setter Property="Focusable" Value="False"/>
                                                    <Setter Property="Background" Value="Transparent"/>
                                                    <Setter Property="Template">
                                                        <Setter.Value>
                                                            <ControlTemplate TargetType="{x:Type RepeatButton}">
                                                                <Border Background="{TemplateBinding Background}"/>
                                                            </ControlTemplate>
                                                        </Setter.Value>
                                                    </Setter>
                                                </Style>
                                            </RepeatButton.Style>
                                        </RepeatButton>
                                    </Track.IncreaseRepeatButton>
                                    <Track.Thumb>
                                        <Thumb x:Name="Thumb">
                                            <Thumb.Style>
                                                <Style TargetType="{x:Type Thumb}">
                                                    <Setter Property="OverridesDefaultStyle" Value="True"/>
                                                    <Setter Property="Height" Value="6"/>
                                                    <Setter Property="Width" Value="6"/>
                                                    <Setter Property="Template">
                                                        <Setter.Value>
                                                            <ControlTemplate TargetType="{x:Type Thumb}">
                                                                <Border CornerRadius="5" x:Name="ForegroundRect">
                                                                    <Border.Effect>
                                                                        <DropShadowEffect Color="{TemplateBinding Foreground}" ShadowDepth="0" BlurRadius="5" />
                                                                    </Border.Effect>
                                                                    <Ellipse x:Name="ForegroundEllipse" Fill="{TemplateBinding Foreground}" Margin="-1" Opacity="1"/>
                                                                </Border>
                                                                <ControlTemplate.Triggers>
                                                                    <Trigger Property="IsMouseOver" Value="True">
                                                                        <Trigger.EnterActions>
                                                                            <BeginStoryboard>
                                                                                <Storyboard AutoReverse="True" RepeatBehavior="Forever">
                                                                                    <DoubleAnimation To="20" Duration="0:0:1" Storyboard.TargetName="ForegroundRect" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.BlurRadius)" />
                                                                                </Storyboard>
                                                                            </BeginStoryboard>
                                                                        </Trigger.EnterActions>
                                                                        <Trigger.ExitActions>
                                                                            <BeginStoryboard>
                                                                                <Storyboard>
                                                                                    <DoubleAnimation To="5" Duration="0:0:0.2" Storyboard.TargetName="ForegroundRect" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.BlurRadius)" />
                                                                                </Storyboard>
                                                                            </BeginStoryboard>
                                                                        </Trigger.ExitActions>
                                                                    </Trigger>
                                                                </ControlTemplate.Triggers>
                                                            </ControlTemplate>
                                                        </Setter.Value>
                                                    </Setter>
                                                </Style>
                                            </Thumb.Style>
                                        </Thumb>
                                    </Track.Thumb>
                                </Track>
                            </Grid>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Application.Resources>
</Application>
